while [ 1 -gt 0  ]; do
expiry=`tokens | grep -e "Expires" | rev | cut -d"s" -f1 | rev | cut -d"]" -f1`
expiryepoch=`date -d "$expiry" '+%s'`
echo $expiry
echo $expiryepoch
now=`date '+%s'`
echo "now:"$now
timeleft=`echo $expiryepoch - $now | bc`
echo $timeleft - 18000 | bc
if [  $(echo $timeleft \<= 18000 | bc) -eq 1 ]; then
  echo "Less than 5 hours to the expiry of the token!"
  mail -s "AFS ticket will expire in less than 5h" roberto.franceschini@cern.ch < /dev/null
fi
sleep 3600
done
